{% extends "bootstrap/base.html" %}

{% block title %}Demo小站{% endblock %}

{% block styles %}
<link rel="stylesheet" href="/static/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="/static/styles.css" type="text/css">
{% endblock %}

{% block head %}
{{ super() }}
<link rel="icon" href="{{ url_for('static',filename='icon.png')}}" type="image/png">
{% endblock %}

{% block navbar %}
<div class="navbar navbar-inverse" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{{ url_for('main.index') }}">Demo小站</a>
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li><a href="{{ url_for('main.index') }}">主页</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                {% if current_user.is_authenticated %}
                    <li><a href="{{ url_for('auth.change_email') }}">更换邮箱</a></li>
                    <li><a href="{{ url_for('auth.change_password') }}">修改密码</a></li>
                    {% if current_user.can(Permission.MODRATE_COMMENTS) %}
                        <li><a href="{{ url_for('main.manage_comment') }}">管理评论</a></li>
                    {% endif %}
                    <li><a href="{{url_for('main.userinfo',username = current_user.username)}}">个人信息</a></li>
                    <li><a href="{{ url_for('auth.logout') }}">注销</a></li>
                {% else %}
                    <li><a href="{{ url_for('auth.login') }}">登录</a></li>
                    <li><a href="{{ url_for('auth.register') }}">注册</a></li>
                {% endif %}
            </ul>
        </div>
    </div>
</div>
{% endblock %}

{% block content %}
<div class="container">
    {% for message in get_flashed_messages() %}
    <div class="alert alert-warning">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        {{ message }}
    </div>
    {% endfor %}

    {% block page_content %}{% endblock %}
</div>
{% endblock %}

{% block scripts %}
    <script src="/static/jquery.min.js"></script>
    <script src="/static/moment-with-locales.min.js"></script>
    <script>
    moment.locale("zh-cn");
    function flask_moment_render(elem) {
        $(elem).text(eval('moment("' + $(elem).data('timestamp') + '").' + $(elem).data('format') + ';'));
        $(elem).removeClass('flask-moment').show();
    }
    function flask_moment_render_all() {
        $('.flask-moment').each(function() {
            flask_moment_render(this);
            if ($(this).data('refresh')) {
                (function(elem, interval) { setInterval(function() { flask_moment_render(elem) }, interval); })(this, $(this).data('refresh'));
            }
        })
    }
    $(document).ready(function() {
        flask_moment_render_all();
    });
    </script>
    <script src="/static/bootstrap.min.js"></script>
{% endblock %}